<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<link href="__STATIC__/css/admin/style.css" rel="stylesheet"/>
	<title><?php echo L('website_manage');?></title>
	<script>
	var URL = '__URL__';
	var SELF = '__SELF__';
	var ROOT_PATH = '__ROOT__';
	var APP	 =	 '__APP__';
	//语言项目
	var lang = new Object();
	<?php $_result=L('js_lang');if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?>lang.<?php echo ($key); ?> = "<?php echo ($val); ?>";<?php endforeach; endif; else: echo "" ;endif; ?>
	</script>
</head>

<body>
<div id="J_ajax_loading" class="ajax_loading"><?php echo L('ajax_loading');?></div>
<?php if(($sub_menu != '') OR ($big_menu != '') OR ($ajaxMenuList != '')): ?><div class="subnav">
    <div class="content_menu ib_a blue line_x">
    	<?php if(!empty($big_menu)): ?><a class="add fb J_showdialog" href="javascript:void(0);" data-uri="<?php echo ($big_menu["iframe"]); ?>" data-title="<?php echo ($big_menu["title"]); ?>" data-id="<?php echo ($big_menu["id"]); ?>" data-width="<?php echo ($big_menu["width"]); ?>" data-height="<?php echo ($big_menu["height"]); ?>"><em><?php echo ($big_menu["title"]); ?></em></a>　<?php endif; ?>

        <?php if(!empty($ajaxMenuList)): if(is_array($ajaxMenuList)): foreach($ajaxMenuList as $key=>$big_menu): ?><a class="add fb J_showdialog" href="javascript:void(0);" data-uri="<?php echo ($big_menu["iframe"]); ?>" data-title="<?php echo ($big_menu["title"]); ?>" data-id="<?php echo ($big_menu["id"]); ?>" data-width="<?php echo ($big_menu["width"]); ?>" data-height="<?php echo ($big_menu["height"]); ?>"><em><?php echo ($big_menu["title"]); ?></em></a>　<?php endforeach; endif; endif; ?>      
        <?php if(!empty($sub_menu)): if(is_array($sub_menu)): $key = 0; $__LIST__ = $sub_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($key % 2 );++$key; if($key != 1): ?><span>|</span><?php endif; ?>
        <a href="<?php echo U($val['moduleName'].'/'.$val['actionName'],array('menuid'=>$menuid)); echo ($val["data"]); ?>" class="<?php echo ($val["class"]); ?>"><em><?php echo L($val['name']);?></em></a><?php endforeach; endif; else: echo "" ;endif; endif; ?>
    </div>
</div><?php endif; ?>
<!--编辑管理员-->
<div class="pad_lr_10">
	<div class="col_tab">
		<ul class="J_tabs tab_but cu_li">
			<li class="current">编辑账号</li>			
		</ul>
     <div class="content_list pad_10">   
	<form id="info_form" name="info_form" action="<?php echo u('admin/edit');?>" method="post">
    <input type="hidden" name="id" value="<?php echo ($info["id"]); ?>" />
	<table width="100%" class="table_form">
		<tr> 
	      <th width="80"><?php echo L('admin_userName');?> :</th>
	      <td><input type="text" name="userName" id="J_userName" value="<?php echo ($info["userName"]); ?>" class="input-text"></td>
	    </tr>
	    <tr> 
	      <th><?php echo L('passWord');?> :</th>
	      <td><input type="text" name="passWord" id="J_password" value="" class="input-text"></td>
	    </tr>
	    <tr>
	    	<th><?php echo L('user_phone');?> :</th>
	    	<td><input type="text" name="phone" class="input-text" value="<?php echo ($info["phone"]); ?>" size="30"></td>
	    </tr>        
	    <tr>
	    	<th><?php echo L('admin_email');?> :</th>
	    	<td><input type="text" name="email" class="input-text" value="<?php echo ($info["email"]); ?>" size="30"></td>
	    </tr>  

        <?php if($_SESSION['admin']['roleId'] != 1): ?><tr>
	    	<th><?php echo L('real_name');?> :</th>
	    	<td><input type="text" name="realName" class="input-text" value="<?php echo ($info["realName"]); ?>"  size="30"></td>
	    </tr>
      
        
	    <tr>
	    	<th><?php echo L('user_company');?> :</th>
	    	<td><input type="text" name="company" class="input-text" value="<?php echo ($info["company"]); ?>" size="30"></td>
	    </tr>        
 	    <tr>
	    	<th><?php echo L('user_job_post');?> :</th>
	    	<td><input type="text" name="jobPost" class="input-text" value="<?php echo ($info["jobPost"]); ?>" size="30"></td>
	    </tr>        
       

	    <tr>
	      <th><?php echo L('admininrole');?> :</th>
	      <td>
	      	<select name="roleId" id="roleId">
                <option value=""><?php echo L('please_select');?></option>
	        	<?php if(is_array($role_list)): $i = 0; $__LIST__ = $role_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><option value="<?php echo ($val["id"]); ?>" level_id="<?php echo ($val["regionLevel"]); ?>" select_customer="<?php echo ($val["selectCustomer"]); ?>" 
                    <?php if($info['roleId'] == $val['id']): ?>selected="true"<?php endif; ?>>
                    <?php echo ($val["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
	        </select>
            
	      </td>
	    </tr>
 	    <tr>
	      <th><?php echo L('select_region');?> :</th>
	      <td>
                    <select class="J_cate_select mr10" data-pid="0" data-uri="<?php echo U('region/ajax_getchilds');?>" data-selected=""></select>
                    <input type="hidden" name="regionId" id="J_cate_id" value="<?php echo ($search["cate_id"]); ?>" />            
	      </td>
	    </tr>
       
       <tr>
            <th>入职时间:</th>
            <td><input type="text" name="entryTime" value="<?php echo ($info["entryTime"]); ?>" /></td>
       </tr>  
       
       <tr>
            <th>离职时间:</th>
            <td><input type="text" name="leavingTime" value="<?php echo ($info["leavingTime"]); ?>" /></td>
       </tr>
       
       <tr>
            <td colspan=2>
            <table>
                <tr>
                    <th>培训时间：</th>
                    <td><input type="text" name="trainTime" value="<?php echo ($userTrain["trainTime"]); ?>" /></td>
                    <th>培训内容：</th>
                    <td colspan=2><input type="text" name="trainCon" value="<?php echo ($userTrain["trainCon"]); ?>" /></td>
                </tr>
                <tr>
                    <th>原职位：</th>
                    <td><input type="text" name="oldPosition" value="<?php echo ($userHistory["oldPosition"]); ?>" /></td>
                    <th>调职时间：</th>
                    <td><input type="text" name="transferTime" value="<?php echo ($userHistory["transferTime"]); ?>" /></td>                    
                </tr>                
            </table>
            </td>
       </tr><?php endif; ?>            
	</table>

    </div>
    </div>
    <div class="mt10"><input type="submit" value="<?php echo L('submit');?>" id="dosubmit" name="dosubmit" class="btn btn_submit" style="margin:0 0 10px 100px;"><br /><br /><br /></div>
</div>
	</form>
<script src="__STATIC__/js/jquery/jquery.js"></script>
<script src="__STATIC__/js/jquery/plugins/jquery.tools.min.js"></script>
<script src="__STATIC__/js/jquery/plugins/formvalidator.js"></script>
<script src="__STATIC__/js/pinphp.js"></script>
<script src="__STATIC__/js/admin.js"></script>
<script>
//初始化弹窗
(function (d) {
    d['okValue'] = lang.dialog_ok;
    d['cancelValue'] = lang.dialog_cancel;
    d['title'] = lang.dialog_title;
})($.dialog.defaults);
</script>

<?php if(isset($list_table)): ?><script src="__STATIC__/js/jquery/plugins/listTable.js"></script>
<script>
$(function(){
	$('.J_tablelist').listTable();
});
</script><?php endif; ?>
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	var check_name_url = "<?php echo U('admin/ajax_check_name', array('id'=>$info['id']));?>";	
	$("#J_userName").formValidator({ onshow:lang.please_input+lang.admin_username, onfocus:lang.please_input+lang.admin_username}).inputValidator({ min:1, onerror:lang.please_input+lang.admin_username}).ajaxValidator({type:"get", url:check_name_url, data:"", datatype:"html", async:'false', success:function(data){ if(data == "1"){return true;}else{return false;}}, onerror:lang.admin_name_exists, onwait:lang.connecting_please_wait});
    
	//$("#J_password").formValidator({ onshow:lang.please_input+lang.password+lang.default_password, onfocus:lang.password+lang.between_6_to_20}).inputValidator({min:0, max:20, onerror:lang.password+lang.between_6_to_20, oncorrect:"d"});
    



});    
    
    $("#roleId").change(function(){       
        var _this = $(this);
        var role_id = _this.val();        
        var option=$("option:selected",_this);
        var level_id = option.attr("level_id");
        var select_customer = option.attr("select_customer");
        level_id = Number(level_id);
        $(".J_cate_select:first").attr('data-selected',"");
        if(role_id){
            var data_uri = "/index.php?g=admin&m=region&a=ajax_getchilds&max_level="+level_id;
            if(level_id>2){
                data_uri +="&type=store";
            }
            $(".J_cate_select").attr("data-uri",data_uri);
            $('.J_cate_select').empty();
            $('.J_cate_select').cate_select();
            
            // 需要选择客户
            if(select_customer==1){
                $("#customerIds").show();
            }else{
                $("input[name='customerIds[]']").each(function(){
                   $(this).attr("checked",false);
                });              
                $("#customerIds").hide();
            }
        }       
    });


    //imei 和 sim 层的显示与隐藏
    var speed = 1500;
    $("#iframe_sim").hide();
    $("#iframe_imei").hide();
    $("#select_sim").click(function(){
       $("#iframe_sim").show(speed); 
    });    
    $("#imei_con").focus(function(){
        $("#iframe_imei").show(speed); 
    });   
    $("#sim_con").focus(function(){
        $("#iframe_sim").show(speed); 
    });    
    $("#select_imei").click(function(){
       $("#iframe_imei").show(speed); 
    });   
    $("#sim_con").focusout(function(){     
        $("#iframe_sim").hide(speed);
    });
    $("#imei_con").focusout(function(){     
        $("#iframe_imei").hide(speed);
    });    
    function select_imei_click(v){
         $("#imei_con").val(v);
         $("#iframe_imei").hide(speed);
    }
    function select_sim_click(v){
         $("#sim_con").val(v);
         $("#iframe_sim").hide(speed);
    }
    
     //取地区路径
    var storeId = "<?php echo ($info['storeId']); ?>";
    var ajax_get_spid = "<?php echo U('region/ajax_get_spid', array('id'=>$info['regionId']));?>";
    var regionId = "<?php echo ($info['regionId']); ?>";
    
    $.ajax({url:ajax_get_spid,success:function(con){
       if(storeId!=""){
            con +=regionId+"_"+storeId+"|";
       }
       $('.J_cate_select').attr('data-selected',con+"");
            var level_id = "<?php echo ($role_list[$info['roleId']]['regionLevel']); ?>";
            var data_uri = "/index.php?g=admin&m=region&a=ajax_getchilds&max_level="+level_id;
            
            if(level_id>2){
                data_uri +="&type=store";
            }
            $(".J_cate_select").attr("data-uri",data_uri);       
       
       //联动查询
    	$('.J_cate_select').cate_select();    
        //$("#roleId").change();    
    }});
        
    
</script>

</body>
</html>